package com.wjboot.wxminiapp.controller;

import cn.binarywang.wx.miniapp.api.WxMaService;
import com.wjboot.wxminiapp.service.WxCheckService;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 微信内容校检
 * @author wj
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/wx/ma/check")
public class WxCheckContentController {
    private final WxMaService wxMaService;

    private final WxCheckService wxCheckService;


    /**
     * 校验内容
     * @param content
     * @return
     * @throws IOException
     */
    @GetMapping("/content/{content}")
    public Boolean checkContent(@PathVariable String content) throws WxErrorException {
        return wxCheckService.checkContent(content);
    }

    /**
     * 校验图片
     * @param multipartFile
     * @return
     */
    @PostMapping("/image")
    public Boolean checkImage(@RequestPart(value = "file") MultipartFile multipartFile) throws WxErrorException {
        return wxCheckService.checkImage(multipartFile);
    }
}
